Crate wast[−][src]
Expand description
A crate for low-level parsing of the WebAssembly text formats: WAT and WAST.
This crate is intended to be a low-level detail of the wat
crate,
providing a low-level parsing API for parsing WebAssembly text format
structures. The API provided by this crate is very similar to
syn
and provides the ability to write customized
parsers which may be an extension to the core WebAssembly text format. For
more documentation see the parser
module.
High-level Overview
This crate provides a few major pieces of functionality
-
lexer
- this is a raw lexer for the wasm text format. This is not customizable, but if you’d like to iterate over raw tokens this is the module for you. You likely won’t use this much. -
parser
- this is the workhorse of this crate. Theparser
module provides theParse
trait primarily and utilities around working with aParser
to parse streams of tokens. -
Module
- this contains an Abstract Syntax Tree (AST) of the WebAssembly Text format (WAT) as well as the unofficial WAST format. This also has aModule::encode
method to emit a module in its binary form.
Stability and WebAssembly Features
This crate provides support for many in-progress WebAssembly features such
as reference types, multi-value, etc. Be sure to check out the documentation
of the wast
crate for policy information on crate
stability vs WebAssembly Features. The tl;dr; version is that this crate
will issue semver-non-breaking releases which will break the parsing of the
text format. This crate, unlike wast
, is expected to have numerous Rust
public API changes, all of which will be accompanied with a semver-breaking
release.
Compile-time Cargo features
This crate has a wasm-module
feature which is turned on by default which
includes all necessary support to parse full WebAssembly modules. If you
don’t need this (for example you’re parsing your own s-expression format)
then this feature can be disabled.
Modules
Common annotations used to parse WebAssembly text files.
Common keyword used to parse WebAssembly text files.
Definition of a lexer for the WebAssembly text format.
Traits for parsing the WebAssembly Text format
Macros
A macro, like custom_keyword
, to create a type which can be used to
parse/peek annotation directives.
A macro to create a custom keyword parser.
A macro for defining custom reserved symbols.
Structs
An alias
statement used to juggle indices with nested modules.
An array type with fields.
Extra information associated with block-related instructions.
Extra information associated with the br_table
instruction.
Extra data associated with the call_indirect
instruction.
A wasm custom section within a module.
A data
directive in a WebAssembly module.
An elem
segment in a WebAssembly module.
A convenience error type to tie together all the detailed errors produced by this crate.
A entry in a WebAssembly module’s export section.
The type of an exported item from a module or instance.
An expression, or a list of instructions, in the WebAssembly text format.
A parsed floating-point type
A parsed floating-point type
A WebAssembly function to be inserted into a module.
Extra information associated with the func.bind instruction.
A function type with parameters and results.
A function type with parameters and results.
A WebAssembly global in a module
Type for a global
in a wasm module
Lanes being shuffled in the i8x16.shuffle
instruction
An identifier in a WebAssembly module, prefixed by $
in the textual
format.
An import
statement and entry in a WebAssembly module.
Convenience structure to parse $f
or (item $f)
.
A listing of inline (export "foo")
statements on a WebAssembly item in
its textual format.
A listing of a inline (import "foo")
statement.
A nested WebAssembly instance to be created as part of a module.
Arguments to the instantiate
instruction
A type for a nested instance
A convenience type to use with Parser::peek
to see if the next token is an s-expression.
Payload for lane-related instructions. Unsigned with no + prefix.
Extra information associated with the let instruction.
Min/max limits used for tables/memories.
Min/max limits used for 64-bit memories
Extra data associated with the loadN_lane
and storeN_lane
instructions.
A local for a func
or let
instruction.
Payload for memory-related instructions indicating offset/alignment of memory accesses.
A defined WebAssembly memory instance inside of a module.
Extra data associated with unary memory instructions.
Extra data associated with the memory.copy
instruction
Extra data associated with the memory.init
instruction
A parsed WebAssembly module.
A type for a nested module
An @name
annotation in source, currently of the form @name "foo"
Representation of the results of name resolution for a module.
A nested WebAssembly nested module to be created as part of a module.
A reference type in a wasm module.
Payload of the select
instructions
A position in the original source stream, used to render errors.
Extra data associated with the struct.get/set
instructions
A field of a struct type.
A struct type with fields.
A WebAssembly table
directive in a module.
Extra data associated with unary table instructions.
Extra data associated with the table.copy
instruction.
Extra data associated with the table.init
instruction
Configuration for a table of a wasm mdoule
A WebAssembly tag directive, part of the exception handling proposal.
A type declaration in a module
A reference to a type defined in this module.
A parsed representation of a *.wast
file.
A *.wat
file parser, or a parser for one parenthesized module.
Enums
An expression that is valid inside an assert_return
directive.
Possible locations to place a custom section within a module.
Known sections that custom sections can be placed relative to.
Different kinds of data segments, either passive or active.
Differnet ways the value of a data segment can be defined.
Different ways to define an element segment in an mdoule.
Different ways to define the element segment payload in a module.
Different kinds of elements that can be exported from a WebAssembly module,
contained in an Export
.
Possible ways to define a function in the text format.
Different kinds of globals that can be defined in a module.
A heap type for a reference type
A reference to another item in a wasm module.
Possible ways to define a instance in the text format.
A listing of all WebAssembly instructions that can be in a module that this crate currently parses.
Parses (func $foo)
Different syntactical ways a memory can be defined in a module.
Configuration for a memory of a wasm module
A listing of all possible fields that can make up a WebAssembly module.
The different kinds of ways to define a module.
Either a NaN pattern (nan:canonical
, nan:arithmetic
) or a value of type T
.
Possible ways to define a nested module in the text format.
The types of values that may be used in a struct or array.
Different ways to textually define a table.
Different kinds of tags that can be defined in a module.
Listing of various types of tags that can be defined in a wasm module.
A definition of a type.
Different ways to specify a v128.const
instruction
A version of V128Const
that allows NanPattern
s.
The value types for a wasm module.
The different kinds of directives found in a *.wast
file.